
package com.actions;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author victor
 */
public class LoginAction extends org.apache.struts.action.Action {
    
     private static final String COMUN = "UsuarioComun";
     private static final String ADMIN = "AdministradorMenu";
       
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        LoginActionForm miForm = (LoginActionForm)form;

        // No se utiliza ya que viene cargado en la variable request
        // de sesión en la validación del ActionForm
        /* String Nick = miForm.getNick();
        String Pass = miForm.getPass();

        request.getSession().setAttribute("Nick", Nick);
        request.getSession().setAttribute("Pass", Pass); */
         request.setAttribute("nick","nick");
        if  (request.getSession().getAttribute("Tipo").equals("Admin"))
            return mapping.findForward(ADMIN);
        else
            return mapping.findForward(COMUN);
    }
    // No necesito llamar a la fachada desde aquí
}
